import * as channelService from '../services/service.js'
export default {
    namespace: 'channel',
     state: {
        num: 3, // state里能定义一些默认值，key:value形式
        : '',
      },
  
    subscriptions: {
      setup({ dispatch, history }) {  // eslint-disable-line
      },
    },
  
    effects: {
      *fetch({ payload }, { call, put }) {  // eslint-disable-line
        yield put({ type: 'save' });
      },
      * fetchChannel({payload}, {call, put}){
         const response=yield call(channelService.fetchChannel,payload);
         if (!response || response.code !='0') {
            return false;
          }
          //存储数据源,发送事件至reducers中
          yield put({
            type: 'saveFetchChannelData',
            payload: response.data,
          });
          return true;
      }
    },
  
    reducers: {
      save(state, action) {
        return { ...state, ...action.payload };
      },
      saveFetchChannelData(state,action){
         return {
             ...state,
             list:action.payload.response,
         }
      }
    },
  
  };
  